package data;

import java.awt.Image;
import java.util.Date;

/**
 * Data holder for an item
 * 
 * @author Kelsey
 */
public class Item {

	/** The status of a listed item */
	public enum Status {
		Open, Resolved
	};

	/** The category an item is listed as */
	public enum Category {
		Keepsake, Heirloom, Misc
	};

	/** The type of item found. If it was lost, found, etc. */
	public enum ItemType {
		ItemFound, ItemDonated, ItemLost, ItemRequested
	};

	/** The name of the account the added the item */
	private String accountName;

	/** The name of the item */
	private String name;

	/** A description of the item */
	private String description;

	/** The status of the item */
	private Status status;

	/** The type of the item */
	private ItemType type;

	/** The category of the item */
	private Category category;

	/** A picture of the item */
	private Image picture;

	/** The date the item was added */
	private Date dateEntered;

	/** The location the item is at, was lost at, or is needed at */
	private String location;

	/**
	 * Creates an item with its dateEntered as the current date
	 */
	public Item() {
		dateEntered = new Date();
	}

	/**
	 * Gets the type of the item - either Donated, Found, Lost, or Requested.
	 * 
	 * @return enum that is ItemType
	 */
	public ItemType getType() {
		return type;
	}

	/**
	 * Set the type of the item - either Donated, Found, Lost, or Requested.
	 * 
	 * @param type
	 *            enum of ItemType
	 */
	public void setType(ItemType type) {
		this.type = type;
	}

	/**
	 * Gets the category of the item - either Heirloom, Keepsake, or Misc.
	 * 
	 * @return enum that is category
	 */
	public Category getCategory() {
		return category;
	}

	/**
	 * Set the category of the item - either Heirloom, Keepsake, or Misc.
	 * 
	 * @param category
	 *            enum of Category.
	 */
	public void setCategory(Category category) {
		this.category = category;
	}

	/**
	 * Gets account name associated with Item.
	 * 
	 * @return String representing account name of Item.
	 */
	public String getAccountName() {
		return accountName;
	}

	/**
	 * Sets new account name for Item.
	 * 
	 * @param name
	 *            String representing new account name of Item.
	 */
	public void setAccountName(String accountName) {
		this.accountName = accountName;
	}

	/**
	 * Gets name of Item.
	 * 
	 * @return String representing name of Item.
	 */
	public String getName() {
		return name;
	}

	/**
	 * Sets new name for Item.
	 * 
	 * @param name
	 *            String representing new name of Item.
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * Gets description of Item.
	 * 
	 * @return String representing description of Item.
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * Sets new description for Item.
	 * 
	 * @param description
	 *            String representing new description of Item.
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * Gets status of Item - either open or resolved.
	 * 
	 * @return String representing status of Item.
	 */
	public Status getStatus() {
		return status;
	}

	/**
	 * Sets new status for Item - only if "open" or "resolved".
	 * 
	 * @param name
	 *            String representing new status of Item.
	 * @return Boolean describing whether status successfully set
	 */
	public void setStatus(Status status) {
		this.status = status;
	}

	/**
	 * Gets picture of Item.
	 * 
	 * @return Image of Item.
	 */
	public Image getPicture() {
		return picture;
	}

	/**
	 * Sets new picture for Item.
	 * 
	 * @param picture
	 *            new Image for Item.
	 */
	public void setPicture(Image picture) {
		this.picture = picture;
	}

	/**
	 * Gets date that Item entered into system.
	 * 
	 * @return Date representing date that Item entered in system.
	 */
	public Date getDateEntered() {
		return dateEntered;
	}

	/**
	 * Sets date that Item entered into system.
	 * 
	 * @param dateEntered
	 *            Date representing new date of Item.
	 */
	public void setDateEntered(Date dateEntered) {
		this.dateEntered = dateEntered;
	}

	/**
	 * Gets location of Item.
	 * 
	 * @return Android Location object representing current location of Item.
	 */
	public String getLocation() {
		return location;
	}

	/**
	 * Sets new location for Item.
	 * 
	 * @param location
	 *            Android Location object representing new current location.
	 */
	public void setLocation(String location) {
		this.location = location;
	}

	/**
	 * main method used for testing
	 */
	public static void main(String[] args) {
		Item item = new Item();
		System.out.println(item.getDateEntered());
	}

	/**
	 * Returns the string representation of the item
	 */
	@Override
	public String toString() {
		return "Name:\t" + getName() + "\n" + "Date Entered:\t"
				+ getDateEntered() + "\nDescription:\t" + getDescription()
				+ "\nStatus:\t" + getStatus() + "\nCategory:\t" + getCategory();
	}
	
	@Override
	public boolean equals( Object o ) {
		Item i = (Item)o;
		
		if ( !(accountName == i.getAccountName() || (accountName != null && accountName.equals(i.getAccountName()))) ) 
			return false;
		if ( !(name == i.getName() || (name != null && name.equals(i.getName()))) ) 
			return false;
		if ( !(description == i.getDescription() || (description != null && description.equals(i.getDescription()))) ) 
			return false;
		if ( !(status == i.getStatus() || (status != null && status.equals(i.getStatus()))) ) 
			return false;
		if ( !(type == i.getType() || (type != null && type.equals(i.getType()))) ) 
			return false;
		if ( !(category == i.getCategory() || (category != null && category.equals(i.getCategory()))) ) 
			return false;
		if ( !(dateEntered == i.getDateEntered() || (dateEntered != null && dateEntered.equals(i.getDateEntered()))) ) 
			return false;
		if ( !(location == i.getLocation() || (location != null && location.equals(i.getLocation()))) ) 
			return false;
		
		return true;
	}

}
